﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;

namespace SignatureWebApi.Models
{
    /// <summary>
    /// 航班信息数据模板
    /// </summary>
    [BsonIgnoreExtraElements]
    public class FlightMegreIdDataModel
    {

        ///// <summary>
        ///// 任务唯一ID(用时间生成)
        ///// </summary>
        //[BsonId]
        //public ObjectId MissionId { get; set; }
        /// <summary>
        /// 航班信息ID
        /// </summary>
        [BsonElement("a_id")]
        public string FlightMergeId { get; set; }

        /// <summary>
        /// 航班信息更新时间
        /// </summary>
        [BsonElement("u_t")]
        public DateTime UpdateTime { get; set; }

        ///// <summary>
        ///// 航班信息更新时间
        ///// </summary>
        //[BsonElement("a_flt")]
        //public string flt { get; set; }
    }
    /// <summary>
    /// 航班任务存储模型
    /// </summary>
    [BsonIgnoreExtraElements]
    public class FlightMissionDataModel
    {
        /// <summary>
        /// 航班任务Id(coll_merge的objectId)
        /// </summary>
        [BsonElement("_id")]
        [BsonRepresentation(BsonType.ObjectId)]
        public string FlightMergeId { get; set; }
        // ReSharper disable once InconsistentNaming
        private string FMIDSource { get; set; }
        /// <summary>
        /// 航班任务在Merge表中的ObjectId
        /// </summary>
        [BsonElement("FM_Id")]
        // ReSharper disable once InconsistentNaming
        public string FMID
        {
            get
            {
                if (FMIDSource != null)
                {
                    return FMIDSource;
                }
                else
                {
                    return FlightMergeId;
                }
            }
            set { FMIDSource = value; }
        }
        /// <summary>
        /// 进港航班标识
        /// </summary>
        [BsonElement("a_id")]
        // ReSharper disable once InconsistentNaming
        public string a_FFID { get; set; }
        /// <summary>
        /// 出港航班标识
        /// </summary>
        [BsonElement("d_id")]
        // ReSharper disable once InconsistentNaming
        public string d_FFID { get; set; }
        /// <summary>
        /// 签单绑定(绑定表单号)
        /// </summary>
        [BsonElement("SL_Id")]
        public string[] SignatureListIds { get; set; }
        /// <summary>
        /// 进港航班号
        /// </summary>
        [BsonElement("a_flt")]
        // ReSharper disable once InconsistentNaming
        public string a_Flt { get; set; }
        /// <summary>
        /// 出港航班号
        /// </summary>
        [BsonElement("d_flt")]
        // ReSharper disable once InconsistentNaming
        public string d_Flt { get; set; }
        /// <summary>
        /// 最新进港时间
        /// </summary>
        [BsonElement("a_t")]
        // ReSharper disable once InconsistentNaming
        public DateTime? a_Time { get; set; }
        /// <summary>
        /// 最新出港时间
        /// </summary>
        [BsonElement("d_t")]
        // ReSharper disable once InconsistentNaming
        public DateTime? d_Time { get; set; }
        /// <summary>
        /// 航班类型
        /// </summary>
        [BsonElement("flight_type")]
        public string FType { get; set; }
        /// <summary>
        /// 机位
        /// </summary>
        [BsonElement("stand")]
        public string Stand { get; set; }
        /// <summary>
        /// 航空公司
        /// </summary>
        [BsonElement("airline")]
        public string Airline { get; set; }
        /// <summary>
        ///机号
        /// </summary>
        [BsonElement("pnum")]
        public string Pnum { get; set; }
        /// <summary>
        /// 机型
        /// </summary>
        [BsonElement("pmodel")]
        public string Pmodel { get; set; }
        /// <summary>
        /// 航班任务更新时间
        /// </summary>
        [BsonElement("u_t")]
        public DateTime UpdateTime { get; set; }
        /// <summary>
        /// 航班数据细节(导出Excel的新加的数据)
        /// </summary>
        [BsonElement("FlightDetail")]
        public FlightDetail flightDetail { get; set; }
        /// <summary>
        /// 区域
        /// </summary>
        [BsonElement("area")]
        public string Area { get; set; }
        /// <summary>
        /// 桥运行数据细节(导出Excel的新加的数据)
        /// </summary>
        [BsonElement("BridgeDetailData")]
        public DetailDataModel[] BridgeDetailData { get; set; }
        /// <summary>
        /// 空调运行数据细节(导出Excel的新加的数据)
        /// </summary>
        [BsonElement("PcaDetailData")]
        public DetailDataModel[] PcaDetailData { get; set; }
        /// <summary>
        /// 电源运行数据细节(导出Excel的新加的数据)
        /// </summary>
        [BsonElement("AdapterDetailData")]
        public DetailDataModel[] AdapterDetailData { get; set; }

    }
    /// <summary>
    /// 工作任务存储模型
    /// </summary>
    [BsonIgnoreExtraElements]
    public class StaffMissionDataModel
    {
        /// <summary>
        /// 航班标识
        /// </summary>
        [BsonElement("_id")]
        public string Id { get; set; }

        private string FFIDSource { get; set; }

        /// <summary>
        /// 航班标识
        /// </summary>
        [BsonElement("FFID")]
        // ReSharper disable once InconsistentNaming
        public string FFID
        {
            get
            {
                if (FFIDSource!=null)
                {
                    return FFIDSource;
                }
                else
                {
                    return Id;
                }
            }
            set { FFIDSource = value; }
        }

        /// <summary>
        /// 航班号(进出港航班号)
        /// </summary>
        [BsonElement("flt")]
        public string Flt { get; set; }
        /// <summary>
        /// 机位
        /// </summary>
        [BsonElement("stand")]
        public string Stand { get; set; }
        /// <summary>
        /// 机型
        /// </summary>
        [BsonElement("pmodel")]
        public string PModel { get; set; }
        /// <summary>
        /// 机号
        /// </summary>
        [BsonElement("pnum")]
        public string PNum { get; set; }
        /// <summary>
        /// 航班类型(到达/出发)
        /// </summary>
        [BsonElement("sign_io")]
        public string SignIo { get; set; }
        /// <summary>
        /// 航班状态
        /// </summary>
        [BsonElement("ista")]
        public string Ista { get; set; }
        /// <summary>
        /// 航班最新到达或出发时间(模糊认定时间)
        /// </summary>
        [BsonElement("t")]
        public DateTime Time { get; set; }
        /// <summary>
        /// 更新时间
        /// </summary>
        [BsonElement("u_t")]
        public DateTime UpdateTime { get; set; }
        /// <summary>
        /// 工作内容
        /// </summary>
        [BsonElement("content")]
        public string Content { get; set; }
        /// <summary>
        /// 工作人员
        /// </summary>
        [BsonElement("staff")]
        public string[] Staff { get; set; }
        /// <summary>
        /// 任务状态
        /// </summary>
        [BsonElement("MStatus")]
        public MissionStatus MissionStatus { get; set; }
    }
    /// <summary>
    /// 新建签单模型
    /// </summary>
    public class SignatatureCreateModel
    {
        /// <summary>
        /// 签单号
        /// </summary>
        [BsonElement("No")]
        public string No { get; set; }
        /// <summary>
        /// 航班号
        /// </summary>
        [BsonElement("Flt")]
        public string Flt { get; set; }
        /// <summary>
        /// 机位
        /// </summary>
        [BsonElement("Stand")]
        public string Stand { get; set; }
        /// <summary>
        /// 航空公司
        /// </summary>
        [BsonElement("Airline")]
        public string Airline { get; set; }
        /// <summary>
        /// 机号
        /// </summary>
        [BsonElement("Pnum")]
        public string Pnum { get; set; }
        /// <summary>
        /// 机型
        /// </summary>
        [BsonElement("PlaneType")]
        public string PlaneType { get; set; }
        /// <summary>
        /// 航班类型
        /// </summary>
        [BsonElement("FType")]
        public FlightType FType { get; set; }//在coll_flight中是string汉字
        /// <summary>
        /// 桥数据
        /// </summary>
        [BsonElement("bridgeData")]
        public BridgeModel bridgeData { get; set; }
        /// <summary>
        /// 空调数据
        /// </summary>
        [BsonElement("pcaData")]
        public PcaModel pcaData { get; set; }
        /// <summary>
        /// 电源数据
        /// </summary>
        [BsonElement("adapterData")]
        public AdapterModel adapterData { get; set; }
        /// <summary>
        /// 自动桥数据
        /// </summary>
        [BsonElement("AutobridgeData")]
        public BridgeModel AutobridgeData { get; set; }
        /// <summary>
        /// 自动空调数据
        /// </summary>
        [BsonElement("AutopcaData")]
        public PcaModel AutopcaData { get; set; }
        /// <summary>
        /// 自动电源数据
        /// </summary>
        [BsonElement("AutoadapterData")]
        public AdapterModel AutoadapterData { get; set; }
        ///// <summary>
        ///// 客梯车数据(数组)
        ///// </summary>
        //[BsonElement("PsData")]
        //public PassengerStepData[] PsData { get; set; }
        /// <summary>
        /// 使用情况
        /// </summary>
        [BsonElement("Usage")]
        public string Usage { get; set; }
        /// <summary>
        /// 签名时间
        /// </summary>
        [BsonElement("Time")]
        public DateTime Time { get; set; }
        /// <summary>
        /// 机组签名
        /// </summary>
        [BsonElement("Pic")]
        public byte[] Pic { get; set; }
        /// <summary>
        /// 工作人员签名
        /// </summary>
        [BsonElement("SPic")]
        public byte[] StaffSignPic { get; set; }
        /// <summary>
        /// 签单状态
        /// </summary>
        [BsonElement("Status")]
        public SignatureStatus Status { get; set; }
        /// <summary>
        /// 签单创建用户Id
        /// </summary>
        [BsonElement("User")]
        public string User { get; set; }
        /// <summary>
        /// 是否已绑定
        /// </summary>
        [BsonElement("IsBind")]
        public bool IsBind { get; set; }
        /// <summary>
        /// 是否系统创建
        /// </summary>
        [BsonElement("SysBuild")]
        public bool SysBuild { get; set; }
        /// <summary>
        /// 更新时间
        /// </summary>
        [BsonElement("UpdateTime")]
        public DateTime UpdateTime { get; set; }
        /// <summary>
        /// 最后一次更新形式
        /// </summary>
        public SignatureUpdateType LastUpdateType { get; set; }
        /// <summary>
        /// 签单类型
        /// </summary>
        [BsonElement("Stype")]
        public SignatureType SignatureType { get; set; }
        /// <summary>
        /// 航班数据细节(导出Excel的新加的数据)
        /// </summary>
        [BsonElement("FlightDetail")]
        public FlightDetail FlightDetail { get; set; }
    }
    public class ArrivalFlightDetailModel
    {
        /// <summary>
        /// 航班类型
        /// </summary>
        public string a_tatt { get; set; }
        /// <summary>
        /// 航班任务
        /// </summary>
        public string a_fltk { get; set; }
        /// <summary>
        /// 航班线路
        /// </summary>
        public string a_fltR { get; set; }
        /// <summary>
        /// 航班性质
        /// </summary>
        public string a_fltRType { get; set; }
        /// <summary>
        /// 航班状态
        /// </summary>
        public string a_ista { get; set; }
        /// <summary>
        /// 航班状态(混合)
        /// </summary>
        public string a_mist { get; set; }
    }
    public class DepartFlightDetailModel
    {
        /// <summary>
        /// 航班类型
        /// </summary>
        public string d_tatt { get; set; }
        /// <summary>
        /// 航班任务
        /// </summary>
        public string d_fltk { get; set; }
        /// <summary>
        /// 航班线路
        /// </summary>
        public string d_fltR { get; set; }
        /// <summary>
        /// 航班性质
        /// </summary>
        public string d_fltRType { get; set; }
        /// <summary>
        /// 航班状态
        /// </summary>
        public string d_ista { get; set; }
        /// <summary>
        /// 航班状态(混合)
        /// </summary>
        public string d_mist { get; set; }
    }
    [BsonIgnoreExtraElements]
    public class FlightDetail
    {
        public DateTime? Fdt { get; set; }
        public ArrivalFlightDetailModel Adetail { get; set; }
        public DepartFlightDetailModel Ddetail { get; set; }
    }

    /// <summary>
    /// 提前到位时间模型(用于计算航前航后的到位时间来统计设备使用时间)
    /// </summary>
    public class AirlinArriveTimeModel
    {
        /// <summary>
        /// 航空公司代号,匹配任意为Any
        /// </summary>
        [BsonElement("Airline")]
        public string Airline { get; set; }
        /// <summary>
        /// 飞机型号,匹配任意为Any
        /// </summary>
        [BsonElement("Pmodel")]
        public string Pmodel { get; set; }
        /// <summary>
        /// 提前到位时间
        /// </summary>
        [BsonElement("Time")]
        public int Time { get; set; }
    }


}